package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.result.Result;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.T26;
import com.ruoyi.service.IT26Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * token申请Controller
 *
 * @author ruoyi
 * @date 2025-04-22
 */
@RestController
@RequestMapping("/system/T26")
public class T26Controller extends BaseController
{
    @Autowired
    private IT26Service t26Service;

    /**
     * 查询token申请列表
     */

    @GetMapping("/list")
    public TableDataInfo list(T26 t26)
    {
        startPage();
        List<T26> list = t26Service.selectT26List(t26);
        return getDataTable(list);
    }

    /**
     * 导出token申请列表
     */

    @Log(title = "token申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, T26 t26,HttpServletRequest request)
    {
        List<T26> list = t26Service.selectComList(t26,request);
        ExcelUtil<T26> util = new ExcelUtil<T26>(T26.class);
        util.exportExcel(response, list, "token申请数据");
    }

    /**
     * 获取token申请详细信息
     */

    @GetMapping(value = "/{F2601}")
    public AjaxResult getInfo(@PathVariable("F2601") Long F2601)
    {
        return success(t26Service.selectT26ByF2601(F2601));
    }

    /**
     * 新增token申请
     */

    @Log(title = "token申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody T26 t26)
    {
        return toAjax(t26Service.insertT26(t26));
    }

    /**
     * 修改token申请
     */

    @Log(title = "token申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody T26 t26)
    {
        return toAjax(t26Service.updateT26(t26));
    }

    /**
     * 删除token申请
     */

    @Log(title = "token申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{F2601s}")
    public AjaxResult remove(@PathVariable Long[] F2601s)
    {
        return toAjax(t26Service.deleteT26ByF2601s(F2601s));
    }

    @PostMapping("/addApply")
    public Result addApply(@RequestBody T26 t26, HttpServletRequest request)
    {
        try {
            return t26Service.addApply(t26,request);
        } catch (Exception e) {
            return Result.erro(e.getMessage());
        }
    }

    @GetMapping("/comList")
    public TableDataInfo list(T26 t26,HttpServletRequest request)
    {
        List<T26> list = t26Service.selectComList(t26,request);
        return getDataTable(list);
    }

    @PostMapping("/toSuccess")
    public Result toSuccess(@RequestBody T26 t26,HttpServletRequest request)
    {
        try {
            return t26Service.toSuccess(t26,request);
        } catch (Exception e) {
            return Result.erro(e.getMessage());
        }
    }
    @PostMapping("/toRefuse")
    public Result toRefuse(@RequestBody T26 t26,HttpServletRequest request)
    {
        try {
            return t26Service.toRefuse(t26,request);
        } catch (Exception e) {
            return Result.erro(e.getMessage());
        }
    }
    @GetMapping("/getUserList")
    public Result getUserList(HttpServletRequest request)
    {
        return t26Service.getUserList(request);
    }
}
